﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gtkj.CMS.Model;

namespace Gtkj.CMS.Common
{
    /// <summary>
    /// 代码转换
    /// </summary>
    public class FormatHelper
    {
        /// <summary>
        /// 隐藏手机号码
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public static string HidePhone(string phone)
        {
            if (!ValidateHelper.IsMobile(phone))
            {
                return null;
            }
            string hide = "";
            foreach (char item in phone)
            {
                if (hide.Length > 2 && hide.Length < 8)
                {
                    hide += "*";
                }
                else
                {
                    hide += item;
                }
                
            }
            return hide;
        }

        #region 支付方式编码转为汉字
        public static string FormatPayType(int? id)
        {
            var result = "支付宝";
            switch (id)
            {
                case 1: result = "支付宝";
                    break;
            }
            return result;
        }
        #endregion

        #region 门店订单状态编码转为汉字
        public static string FormatOrderDepartmentStatus(int? status)
        {
            var result = "";
            switch (status)
            {
                case 0: result = "已取消";
                    break;
                case 1: result = "待付款";
                    break;
                case 2: result = "用户待评价";
                    break;
                case 3: result = "商家待评价";
                    break;
                case 9: result = "交易完成";
                    break;
            }
            return result;
        }
        #endregion

        #region 线上订单状态编码转为汉字
        public static string FormatOrderStatus(int? status)
        {
            var result = "";
            switch (status)
            {
                case 0: result = "已取消";
                    break;
                case 1: result = "待付款";
                    break;
                case 2: result = "待发货";
                    break;
                case 3: result = "待收货";
                    break;
                case 4: result = "待用户评价";
                    break;
                case 5: result = "待商家评价";
                    break;
                case 9: result = "交易完成";
                    break;
            }
            return result;
        }
        #endregion
    }
}
